<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>layui</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="/lib/layui-v2.6.3/css/layui.css" media="all">
    <link rel="stylesheet" href="/css/public.css" media="all">
    <style>
        body {
            background-color: #ffffff;
        }
    </style>
</head>
<body>
<div class="layui-form layuimini-form">
    <div class="layui-form-item">
        <label class="layui-form-label required">名称：</label>
        <div class="layui-input-block">
            <input type="text" name="name" lay-verify="required" lay-reqtext="名称不能为空" placeholder="请输入名称" value="" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label required">讲师：</label>
        <div class="layui-input-block">
            <select name="teacher" lay-verify="">
                <option value="">请选择讲师</option>
                <option value="王博">王博</option>
                <option value="刘晓磊">刘晓磊</option>
                <option value="邢朋辉">邢朋辉</option>
            </select>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label required">课程：</label>
        <div class="layui-input-block">
            <select name="course" lay-verify="">
                <option value="">请选择课程</option>
                <option value="Java">Java</option>
                <option value="Html5">Html5</option>
                <option value="UI/UE">UI/UE</option>
                <option value="云计算">云计算</option>
                <option value="大数据">大数据</option>
            </select>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label required">周期：</label>
        <div class="layui-input-block">
            <input type="number" name="weeks" lay-verify="required" lay-reqtext="周期不能为空" placeholder="请输入周期" value="" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">开班日期：</label>
        <div class="layui-input-inline" style="width: 100px;">
            <input type="text" id="date1" name="sdate" placeholder="请选择开班日期" autocomplete="off" class="layui-input">
        </div>
        <div class="layui-form-mid">毕业日期：</div>
        <div class="layui-input-inline" style="width: 100px;">
            <input type="text" id="date2" name="edate" placeholder="请选择毕业日期" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label required">位置：</label>
        <div class="layui-input-block">
            <input type="text" name="address" lay-verify="required" lay-reqtext="位置不能为空" placeholder="请输入名称" value="" class="layui-input">
        </div>
    </div>

    <div class="layui-form-item">
        <div class="layui-input-block">
            <button class="layui-btn layui-btn-normal" lay-submit lay-filter="saveBtn">新增班级</button>
        </div>
    </div>
</div>
<script src="/lib/layui-v2.6.3/layui.js" charset="utf-8"></script>
<script>
    layui.use(['form','laydate'], function () {
        var form = layui.form,
            layer = layui.layer,
            laydate = layui.laydate,
            $ = layui.$;

        //渲染日期框
        laydate.render({
            elem: '#date1' //指定元素
        });
        laydate.render({
            elem: '#date2' //指定元素
        });

        //监听提交
        form.on('submit(saveBtn)', function (data) {
            //新增用户 Ajax 请求接口
            $.post('/api/grade/add.do',data.field,function (res){
                if(res.code==0){
                    //成功
                    layer.msg("亲，恭喜你，新增成功！")
                }else {
                    layer.msg("亲。新增失败！");
                }
            })
            return false;
        });
    });
</script>
</body>
</html>